package com.sky.mapper;

import com.sky.entity.DishFlavor;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishFlavorMapper {

    //新增-->菜品口味新增,修改->从dto中提取到新的口味列表,重新保存到口味表
    @Insert("insert into dish_flavor values (null,#{dishId},#{name},#{value})")
    void save(DishFlavor dishFlavor);

    //根据菜品id查询口味列表
    @Select("select * from dish_flavor where dish_id = #{dishId}")
    List<DishFlavor> findByDishId(Long dishId);

    //修改菜品时使用->先删除当前菜品在口味表中的所有记录,在删除时使用->根据菜品id从口味表删除
    @Delete("delete from dish_flavor where dish_id = #{dishId}")
    void deleteByDishId(Long dishId);
}
